const express = require('express')
const router = express.Router()
const mongoose = require('mongoose')
const Style = mongoose.model('Styles')

/* GET home page. */
router.get('/', async function (req, res, next) {
  const styles = await Style.find({pass: true})
  res.send({
    status: true,
    message: 'ok',
    data: styles
  })
})

router.post('/', async function (req, res, next) {
  try {
    await Style.create(req.body)
    res.send({
      status: true,
      message: 'ok',
    })
  } catch (e) {
    res.send({
      status: false,
      message: e.toString(),
    })
  }
})

module.exports = router
